import Department, { type IView } from '../../../selector/department';
import { type TreeOption, userTypePrefix } from '../../../../../types';
import ApprovalService from '../base/service';

class DepartmentService extends ApprovalService<TreeOption> implements IView {
  get options(): TreeOption[] {
    return this.panel?.department.options || [];
  }

  prefix = userTypePrefix.department;

  // options: TreeOption[] = [];
  component = Department;
  value: Array<string | TreeOption> = [];

  onShow() {
    if (this.options.length > 0) return;
    this.initMetaData();
  }

  async initMetaData() {
    await this.panel.department.initData();
    // this.options = this.panel.department.options;
  }

  initData(value: TreeOption[] = []): void {
    this.value = value;
    this.updateProperties(value);
  }
}

export default DepartmentService;
